finding locked Modules

Hello,

For some reason the following code doesn't work for finding locked modules. What am I doing wrong. When I login as "Admin" and open a module in exclusive-edit then login as a different user the code doesn't show th module being locked and going through "Tools" > "Manage Locks" this too doesn't show the lock. Any thoughts

Thank you,
Jim
 

/**********************************
    addItemToList
***********************************/
void addItemToList (Item I)
{
        string ugName = null
        
        ModName_ modRef
        
        LockList lList
        
        Lock lck
        
        int rowNum = 0  
        int count = 0
        
        Item I2
        
        bool itemExists = false
        
        //Check the item isn't all ready in the list.
        for I2 in items do
        {
                if (name (I) == (string key (items)))
                {
                        itemExists = true       
                }
        }
        
        //If not in the list all ready.
        if (!itemExists)
        {
                //Add the formal module.
                if (type (I) == "Formal")
                {
                        modRef = module (fullName (I))
                        
                        //Get the locks on the module if any.
                        lList = getLocksInModule (modRef, true)
                        
                        for lck in lList do
                        {
                                count++
                                ugName = lck.user
                        }             
                        if(count>1){ ugName = ugName "{+}"}
                
                        //Insert the module in the list with with normal icon if not locked.
                        if (!isLocked (modRef) || (isLocked (modRef) && ugName == null))
                        {
                                insert (moduleList, rowNum, name (I), iconFormal)
                                set (moduleList, rowNum, 1, ugName)
                                put (items, name (I), I)                        
                        }
                        //Insert the item in the list with the deleted icon indicating it is locked
                        //and will not be processed.
                        else
                        {
                                insert (moduleList, rowNum, name (I), iconUser)
                                set (moduleList, rowNum, 1, ugName)
                        }
                }
                        
                rowNum++        
        }
        delete(lList)
}//End addItemToList.

SystemAdmin - Fri Jun 22 10:55:50 EDT 2012

Re: finding locked Modules
SystemAdmin - Fri Jun 22 11:37:00 EDT 2012

hello,

I also have another question. Do you have to delete a LockList, if not will you get a memeory leak? when I attempt to delete the LockList I get a memory error(log).

Thank you,
Jim

Re: finding locked Modules
llandale - Fri Jun 22 13:34:55 EDT 2012

I think you are creating a list of Modules in a "list" or "multiList" DBE, and want to indicate whether that module is locked or not.

This does not look right.
  1. You must delete the locklist at the same level that you create it (getLocksInModule); demote this line inward two indents, move up (I think) 5 lines:
    • delete(lList)
  2. Likewise you want to increment your row ONLY when you actually use it; demote this line inward one indent; move up (I think) 3 lines:
    • rowNum++
  3. Skip list "items" must have a unique key; "name" may not be unique (e.g. there are two "SubS" modules in the project in different folders); so perhaps use "fullName(I)" instead of "name(I)". However, I'd just use "Item" as the key and find it directly.
  4. Seems to me you should check for Formal at the top; use this at the top and delete the middle check:
    • if (null I or type (I) != "Formal") return
  5. If the module is not locked your logic will allow it to be inserted twice. To avoid that, promote this line one indent level, move up (I think) 5 lines:
    • put (items, name (I), I)

I believe I would do these:
  • The calling program would check for "Formal", and send this function a ModName_ ref.
  • Perhaps use "getLocksInDatabase()", parse into a Skip List, then call this function which looks in the list to determine if it is locked.
  • There is an "ugName" problem; I'd set it only if its currently null.

Failing to delete structures matters as you approach 10,000 such structures. Its' hard to have 10,000 modules but easy to have 10,000 objects. So no there is no problem here; but surely it's good practice to match up a "delete" for each such "create". Good Karma too.

Not sure about your overall problem of not seeing some locks, but perhaps the follow applies:
  • If you have the module open Read and THEN someone else Edits it, I don't think your module locklist is refreshed. You should close the module.
  • The current folder YOU have open matters vis-a-vis the display of locks. Generally, select the Project in the left pane.
  • There is an option to see all locks on that dialog.
  • You must have DB Admin Powers to see anybody else's locks; "Standard" users don't see other folk's locks.

-Louie